package net.qiqbframework.modelling.domain;


import net.qiqbframework.messaging.MetaData;

import static net.qiqbframework.modelling.domain.AggregateLifecycle.getInstance;

public interface AggregateContext {


    static void addEvent(Object payload, MetaData metaData) {
        getInstance().addEvent(payload, metaData);
    }


    static void addEvent(Object payload) {
        getInstance().addEvent(payload, MetaData.emptyInstance());
    }

    static void addEvents(Object... payloads) {
        for (Object payload : payloads) {
            getInstance().addEvent(payload, MetaData.emptyInstance());
        }
    }


    static boolean isLive() {
        return getInstance().getIsLive();
    }

    static boolean isDeleted() {
        return getInstance().isDeleted();
    }

    /**
     * 获取聚合版本号
     *
     * @return
     */
    static Long getVersion() {
        return getInstance().version();
    }

    static Object getAggregateRoot() {
        return getInstance().aggregateRoot();
    }

    /**
     * 设置当前聚合根删除状态
     */
    static void markDeleted() {
        getInstance().doMarkDeleted();
    }

    static void updateFetchSource(Integer fetchSource) {
        getInstance().updateFetchSource(fetchSource);
    }



}
